function getdataset(url){

var ajax_load = "<img class='loading' src='./views/images/loading.gif'  alt='loading...' />";

$('#datasetvalue').html(ajax_load);



var param=getMaesureParameters(url.toString());

$.ajax({
    url: './index.php',
    type: 'POST',
	data:"uri="+param[0]+"&endpoint="+param[1]+"&rt=dataset/view",
    timeout: 1000,
	dataType:"json",
    error: function(){
        alert('No dataset exists...');
    },
    success: function(responseText){
	if(responseText.status==="ok"){
     fillInterfaceWithJsonObjectOfdataset(responseText.dataset,param);
	}
	else
	{
      alert('No dataset exists...');
	}
    }
});

$('#slidepanel').append(
	$(document.createElement('a'))
	.attr('id','trigger1')
	.addClass('trigger left')
	.html('Search').attr('href','./index.php?uri='+param[0]+'&endpoint='+param[1]+'&rt=dataset/search'));
	

}


function fillInterfaceWithJsonObjectOfdataset(dataset,param){
 
  $('#datasetvalue').html("");
	 var table=$(document.createElement('table')).addClass('datasettable').width('100%');
	 var tr=$(document.createElement('tr')).width('100%').hover(function ()
			{ $(this).addClass("hover");},  function () {$(this).removeClass("hover");});
     var td1=$(document.createElement('td'))
		 .addClass('title');
     td1.append("<span>"+dataset.label+" dataset</span>").attr('colspan','2');
	 tr.append(td1);
     var tr2=$(document.createElement('tr')).width('100%').hover(function ()
			{ $(this).addClass("hover");},  function () {$(this).removeClass("hover");});
	 var td2=$(document.createElement('td')).attr('colspan','2')
		 .addClass('uri').html('URI (if de-referancable)');
	 var anchor=$(document.createElement('a'))
		 .attr('href',dataset.dsuri);
	 var img=$(document.createElement('img'))
		 .attr('src','./views/images/external_link_icon.gif');
     anchor.append(img);
     td2.append(anchor);
	 tr2.append(td2);
     var tr3=$(document.createElement('tr')).width('100%') .addClass('comment').hover(function ()
			{ $(this).addClass("hover");},  function () {$(this).removeClass("hover");});
	 var td3=$(document.createElement('td')).attr('colspan','2')
		.html(dataset.comment);
	 tr3.append(td3);

     var tr4=$(document.createElement('tr')).width('100%').addClass('date').hover(function ()
			{ $(this).addClass("hover");},  function () {$(this).removeClass("hover");});
	 var td4=$(document.createElement('td'))
		 
		 .html(dataset.dsdate);
	  var td44=$(document.createElement('td'))
		  .css('font-weight','bold')
		 .html('Date');
	 tr4.append(td44);
     tr4.append(td4);

	 var tr5=$(document.createElement('tr')).width('100%').addClass('publisher').hover(function ()
			{ $(this).addClass("hover");},  function () {$(this).removeClass("hover");});
	 var td55=$(document.createElement('td'))
		 .css('font-weight','bold')
		 .html('Publisher');
     var td5=$(document.createElement('td'))
		 .html(dataset.publisher);

	 tr5.append(td55);
     tr5.append(td5);

     var tr6=$(document.createElement('tr')).width('100%').hover(function ()
			{ $(this).addClass("hover");},  function () {$(this).removeClass("hover");});
	 var td66=$(document.createElement('td'))
		 .css('font-weight','bold')
		 .addClass('subject').html('Subject');

	 var td6=$(document.createElement('td'))
		 .addClass('subject').html(dataset.subject);

	 tr6.append(td66);
	 tr6.append(td6);

	 table.append(tr);  
	 table.append(tr2);
	 table.append(tr3);
	 table.append(tr4);
	 table.append(tr5);
	 table.append(tr6);
	$('#datasetvalue').append(table);

 }


function getMaesureParameters(url){
var arr=new Array();
 var split1=url.split('?');
 var split2=split1[1].split('&');
 for(i=0;i<split2.length;i++){
    var split3=split2[i].split('=');
	if(split3[0]=="uri"){
	  arr[0]=split3[1];
	}
	if(split3[0]=="endpoint"){
	  arr[1]=split3[1];
	}
	if(split3[0]=="rt"){
	  arr[2]=split3[1];
	}
 }

return arr;
}


